/*
							Copyright (C) 2010  Alourien Team
									
						This file is part of the Alourien Engine.

    The Alourien Engine is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    The Alourien Engine is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with the Alourien Engine.  If not, see <http://www.gnu.org/licenses/>.
	
 *File Name: Physics.h
 *Programmer Name:Jose Castellano
 *Date of last update:11/01/2010
 *
 *Purpose:This Program is to provide all the physics that is required in any type
 * of computation for our game.
 *
 *Basic Info: This file includes finding the velocity, the acceleration,
 * the displacement, and more eventually. Header needed, MathClass, vector2D
 * vectorMath
 *
 *UPDATES:
 *1) Added the actual code to our Engine namespace
 *   Date: 10/06/2010 Updater: Manuel Cuellar
 *
 *2) Added the conservation of momentum equations
 *   Date: 10/18/2010 Updater: Jose Castellano
 *
 *3) Changed functions from int to float
 *   Date: 10/27/2010 Updater: Manuel Cuellar
 *
 *4) Fixed the defined constants
 *   Date: 10/27/2010 Updater: Manuel Cuellar 
 *   
 *5) Fixed the Names in order to actually have the functions work
 *   and grouped the functions by their name
 *   Date: 10/28/2010 Updater: Jose Castellano
 *
 *6) Removed macros from the file
 *   Date: 11/01/2010 Updater: Manuel Cuellar
 */

#ifndef _PHYSICS_H
#define _PHYSICS_H 1

#include "Vector2D.h"
#include "VectorMath.h"
#include "MathClass.h"

namespace Alourien
{
	class Physics
	{ 
	public:
		Physics(void);
		~Physics(void);

		MathClass obj;

		//Velocity Equations
		float Velocity1(float displacement, float time); //basic definition of velocity
		float Velocity2(float accel, float time); //Velocity = accel * time
		float Velocity3(float mass, float kineticEnergy); //KineticEnergy = .5f*m*v^2
		float Velocity4(float mass, float momentum); //Momentum = mv
		float Velocity_F1(float velocity_I, float accel, float time); //one of the equations of motion
		float Velocity_F2(float velocity_I, float accel, float displacement);//vf^2 = vi^2+2*a*x
		float Velocity_F3(float velocity_I, float time, float displacement);//x= .5f*t*(vf-vi)
		Vector2D Velocity_F4(Vector2D projection, Vector2D velocity_I);//vf= 2p+vi
		float Velocity_I1(float velocity_F, float accel, float time);//vf=vi +a*t
		float Velocity_I2(float velocity_F, float accel, float displacement);//vf^2 = vi^2+2*a*x
		float Velocity_I3(float displacement, float time, float accel);//x = vi*t+.5f*a*t^2
		float Velocity_I4(float displacement, float time, float accel, float displacement_I);//x = vi*t+.5f*a*t^2 +x0
		float Velocity_I5(float velocity_F, float time, float displacement);//x= .5f*t*(vf-vi)
		float AngVelocity1(float rotDisplacement, float time);//angV=rotD/t
		float AngVelocity2(float angAccel, float time);//angV=angAccel*t
		float AngVelocity3(float radius, float velocityTang);//vT = r*angV
		float AngVelocity4(float kineticEnergyRot, float inertia);
		float AngVelocity5(float inertia, float angMomentum);
		float VelocityTang1(float radius, float angVelocity);//vt = r*angV
		float VelocityTang2(float centripetalF, float radius);//Fcen=vT^2/r
		float VelocityTwo_F(float m1, float v1_I, float m2, float v2_I, float e);//conservation of momentum
		float VelocityOne_F(float v2_F, float e, float v1_I, float v1_F);//coefficient of res
		
		float Displacement1(float time, float velocity);
		float Displacement2(float velocity_I, float velocity_F, float accel);
		float Displacement3(float velocity_I, float time, float accel);
		float Displacement4(float velocity_I, float time, float accel, float displacement_I);
		float Displacement5(float velocity_I, float velocity_F, float time);
		float Displacement6(float work, float force);
		float Displacement_I(float velocity_I, float displacement, float time, float accel);
		float RotDisplacement1(float arcLenght, float radius);
		float RotDisplacement2(float angVelocity, float time);
		
		float Time1(float displacement, float velocity);
		float Time2(float accel, float velocity);
		float Time3(float velocity_I, float velocity_F, float accel);
		float Time4(float velocity_I, float displacement, float accel);
		float Time5(float velocity_I, float displacement, float accel, float displacement_I);
		float Time6(float velocity_I, float velocity_F, float displacement);
		float Time7(float force, float impulse);
		float Time8(float angVelocity, float rotDisplacement);
		float Time9(float angAccel, float angVelocity);
		float Time_I(float time_F, float impulse, float force);
		float Time_F(float time_I, float impulse, float force);

		float Accel1(float velocity, float time);
		float Accel2(float velocity_I, float velocity_F, float time);
		float Accel3(float velocity_I, float velocity_F, float displacement);
		float Accel4(float velocity_I, float displacement, float time);
		float Accel5(float velocity_I, float displacement, float time, float displacement_I);
		float Accel6(float mass, float force);
		float AngAccel1(float angVelocity, float time);
		float AngAccel2(float radius, float accelTang);
		float AngAccel3(float mass, float radius, float torque);
		float AngAccel4(float inertia, float torque);	
		float AccelTang1(float radius, float angAccel);
		float AccelTang2(float mass, float forceTang);
		float AccelTang3(float radius, float torque, float mass);
		float AverageAccel(float velocity_I, float velocity_F);		
			

		float Force1(float mass, float accel);
		float Force2(float work, float displacement);
		float Force3(float time, float impulse);
		float Force4(float time_I, float time_F, float impulse);
		float ForceG(float mass);
		float ForceN(float mass);
		Vector2D ForceGOnIncline(float mass, float angleInDegrees);
		Vector2D ForceNOnIncline(float mass, float angleInDegrees);
		float CentripetalF(float velocityTang, float radius);
		float ForceTang1(float mass, float accelTang);
		float ForceTang2(float radius, float torque);
		
		float Mass1(float force, float accel);
		float Mass2(float weightInLBS);
		float Mass3(float weightInN);
		float Mass4(float forceG);
		float Mass5(float forceN);
		float Mass6(float kineticEnergy, float velocity);
		float Mass7(float potentialEnergy, float height);
		float Mass8(float momentum, float velocity);
		float Mass9(float forceTang, float accelTang);
		float Mass10(float radius, float torque, float accelTang);
		float Mass11(float radius, float torque, float angAccel);
		float Mass12(float inertia, float radius);
				
		float WeightInLBS(float mass);
		float WeightInN(float mass);

		float StaticFriction(float staticCoefficient, float forceN);
		float KineticFriction(float kineticCoefficient, float forceN);

		Vector2D Projection(Vector2D vector1, Vector2D vector2);

		float Work1(float force, float displacement);
		float Work2(float kineticEnergy_I, float kineticEnergy_F);

		float KineticEnergy(float mass, float velocity);
		float KineticEnergy_I(float work, float kineticEnergy_F);
		float KineticEnergy_F(float work, float kineticEnergy_I);
		float KineticEnergyRot(float inertia, float angVelocity);
		
		float PotentialEnergy(float mass, float height);
	
		float Height(float mass, float potentialEnergy);

		float Momentum(float mass, float velocity);	
		float Momentum_I(float momentum_F, float impulse);
		float Momentum_F(float momentum_I, float impulse);
		float AngMomentum(float inertia, float angVelocity);

		float Impulse1(float force, float time);
		float Impulse2(float force, float time_I, float time_F);
		float Impulse3(float momentum_I, float momentum_F);

		float CoeffOfRestitution(float separation, float approach);

		float ArcLenght(float rotDisplacement, float radius);
		
		float Radius1(float rotDisplacement, float arcLenght);
		float Radius2(float velocityTang, float angVelocity);
		float Radius3(float accelTang, float angAccel);
		float Radius4(float velocityTang, float centripetalF);
		float Radius5(float torque, float forceTang);
		float Radius6(float torque, float mass, float accelTang);
		float Radius7(float mass, float torque, float angAccel);
		float Radius8(float mass, float inertia);

		float Torque1(float inertia, float angAccel);
		float Torque2(float mass, float radius, float angAccel);
		float Torque3(float radius, float mass, float accelTang);
		float Torque4(float radius, float forceTang);
		
		float Inertia1(float torque, float angAccel);
		float Inertia2(float mass, float radius);
		float Inertia3(float kineticEnergyRot, float angVelocity);
		float Inertia4(float angMomentum, float angVelocity);
	}; 
};

#endif
